package com.java.ssm.service.impl;

import com.java.ssm.dao.ReceivingDao;
import com.java.ssm.entity.Receiving;
import com.java.ssm.service.ReceivingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Receiving)表服务实现类
 *
 * @author makejava
 * @since 2021-01-21 08:42:15
 */
@Service("receivingService")
public class ReceivingServiceImpl implements ReceivingService {
    @Resource
    private ReceivingDao receivingDao;

    /**
     * 通过ID查询单条数据
     *
     * @param rId 主键
     * @return 实例对象
     */
    @Override
    public Receiving queryById(Integer rId) {
        return this.receivingDao.queryById(rId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Receiving> queryAllByLimit(int offset, int limit) {
        return this.receivingDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param receiving 实例对象
     * @return 实例对象
     */
    @Override
    public Receiving insert(Receiving receiving) {
        this.receivingDao.insert(receiving);
        return receiving;
    }

    /**
     * 修改数据
     *
     * @param receiving 实例对象
     * @return 实例对象
     */
    @Override
    public Receiving update(Receiving receiving) {
        this.receivingDao.update(receiving);
        return this.queryById(receiving.getRId());
    }

    /**
     * 通过主键删除数据
     *
     * @param rId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer rId) {
        return this.receivingDao.deleteById(rId) > 0;
    }
}